/*
 * =====================================================================================
 *
 *       Filename:  myread.c
 *
 *
 *        Created:  10/01/2011 11:02:32 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  durand_y, <durand.yoan@gmail.com>
 *
 * =====================================================================================
 */
#include "myread.h"
#include "iso9660.h"

int         test_open(char  *file)
{
    int     fd = -1;

    if ((fd = open(file, O_RDONLY)) == -1)
     return (0);
    else
    {
        printf("filedexc → %i", fd);
        if (isatty(fd) == 1)
        {
            close(fd);
            return (1);
        }
        else
        {
            close(fd);
            return (0);
        }
    }
}

int							test_iso(char   *file)
{
    int						fd = -1;
    char					*map = NULL;
    struct stat				buff;
	int						jump = 0;

	jump = ISO_PRIM_VOLDESC_BLOCK * ISO_BLOCK_SIZE;
	fd = open(file, O_RDONLY);
    if (fd == -1)
    {
        return (0);
    }
    else
    {
        stat(file, &buff);
        map = mmap(NULL, buff.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
        lseek(fd, jump, SEEK_SET);
		return (1);
    }
}
